Filesystem implementations may need optional arguments in terms of
authorjohn.levon@sun.com <john.levon@sun.com>
Tue, 20 Feb 2007 04:44:42 +0000 (20:44 -0800)
committerjohn.levon@sun.com <john.levon@sun.com>
Tue, 20 Feb 2007 04:44:42 +0000 (20:44 -0800)
what to mount. Add an options string to the libfsimage API.

Signed-off-by: John Levon <john.levon@sun.com>
12 files changed:
tools/libfsimage/common/fsimage.c
tools/libfsimage/common/fsimage.h
tools/libfsimage/common/fsimage_grub.c
tools/libfsimage/common/fsimage_grub.h
tools/libfsimage/common/fsimage_plugin.c
tools/libfsimage/common/fsimage_plugin.h
tools/libfsimage/common/fsimage_priv.h
tools/libfsimage/ext2fs-lib/ext2fs-lib.c
tools/libfsimage/ext2fs/fsys_ext2fs.c
tools/libfsimage/reiserfs/fsys_reiserfs.c
tools/libfsimage/ufs/fsys_ufs.c
tools/pygrub/src/fsimage/fsimage.c

index 08262f81ced3505812c47ded73157c4079a81df6..4a1431751d1a55c5d4af22d8861a458236234077 100644 (file)
@@ -36,7 +36,7 @@
 
 static pthread_mutex_t fsi_lock = PTHREAD_MUTEX_INITIALIZER;
 
-fsi_t *fsi_open_fsimage(const char *path, uint64_t off)
+fsi_t *fsi_open_fsimage(const char *path, uint64_t off, const char *options)
 {
        fsi_t *fsi = NULL;
        int fd;
@@ -53,7 +53,7 @@ fsi_t *fsi_open_fsimage(const char *path, uint64_t off)
        fsi->f_data = NULL;
 
        pthread_mutex_lock(&fsi_lock);
-       err = find_plugin(fsi, path);
+       err = find_plugin(fsi, path, options);
        pthread_mutex_unlock(&fsi_lock);
        if (err != 0)
                goto fail;
index 28165ef29d8eb97ca00c474ccd21cba5f2193d0d..ad305b5dae383f969ca5c278ebc11e677b862ec7 100644 (file)
@@ -35,7 +35,7 @@ extern C {
 typedef struct fsi fsi_t;
 typedef struct fsi_file fsi_file_t;
 
-fsi_t *fsi_open_fsimage(const char *, uint64_t);
+fsi_t *fsi_open_fsimage(const char *, uint64_t, const char *);
 void fsi_close_fsimage(fsi_t *);
 
 int fsi_file_exists(fsi_t *, const char *);
index 99481064a9047cb7f3eaf21257665ac5c1c2c155..27a1481eb76f7aff5e62781b098cd40f35fd3e04 100644 (file)
@@ -161,7 +161,7 @@ fsig_substring(const char *s1, const char *s2)
 }
 
 static int
-fsig_mount(fsi_t *fsi, const char *path)
+fsig_mount(fsi_t *fsi, const char *path, const char *options)
 {
        fsig_plugin_ops_t *ops = fsi->f_plugin->fp_data;
        fsi_file_t *ffi;
@@ -178,7 +178,7 @@ fsig_mount(fsi_t *fsi, const char *path)
 
        bzero(fsi->f_data, sizeof (fsig_data_t));
 
-       if (!ops->fpo_mount(ffi)) {
+       if (!ops->fpo_mount(ffi, options)) {
                fsip_file_free(ffi);
                free(fsi->f_data);
                fsi->f_data = NULL;
index 38db2a219c9fc68771a23e6a36281ee74b0c90df..9fc8c467b265f883b94db8021533acd887e38272 100644 (file)
@@ -38,7 +38,7 @@ extern C {
 
 typedef struct fsig_plugin_ops {
        int fpo_version;
-       int (*fpo_mount)(fsi_file_t *);
+       int (*fpo_mount)(fsi_file_t *, const char *);
        int (*fpo_dir)(fsi_file_t *, char *);
        int (*fpo_read)(fsi_file_t *, char *, int);
 } fsig_plugin_ops_t;
index f9616481649ceb065f5469c4609abb648e0816c8..ab35fb7d8f7d5e9d8e4f63a81846d19e5f4ff5c6 100644 (file)
@@ -185,7 +185,7 @@ fail:
        return (ret);
 }
 
-int find_plugin(fsi_t *fsi, const char *path)
+int find_plugin(fsi_t *fsi, const char *path, const char *options)
 {
        fsi_plugin_t *fp;
        int ret = 0;
@@ -195,7 +195,7 @@ int find_plugin(fsi_t *fsi, const char *path)
 
        for (fp = plugins; fp != NULL; fp = fp->fp_next) {
                fsi->f_plugin = fp;
-               if (fp->fp_ops->fpo_mount(fsi, path) == 0)
+               if (fp->fp_ops->fpo_mount(fsi, path, options) == 0)
                        goto out;
        }
 
index f1c83fab9596aed7daa1347435011a9bb927bcce..a682719a63e47d702cb4c2986be3296f25d08771 100644 (file)
@@ -38,7 +38,7 @@ typedef struct fsi_plugin fsi_plugin_t;
 
 typedef struct fsi_plugin_ops {
        int fpo_version;
-       int (*fpo_mount)(fsi_t *, const char *);
+       int (*fpo_mount)(fsi_t *, const char *, const char *);
        int (*fpo_umount)(fsi_t *);
        fsi_file_t *(*fpo_open)(fsi_t *, const char *);
        ssize_t (*fpo_read)(fsi_file_t *, void *, size_t);
index cf0dfe6612ecab1b0da07546fc70b9527b69752f..441b71930afe40ce35b83948e538ac48ebbe5575 100644 (file)
@@ -53,7 +53,7 @@ struct fsi_file {
        void *ff_data;
 };
 
-int find_plugin(fsi_t *, const char *);
+int find_plugin(fsi_t *, const char *, const char *);
 
 #ifdef __cplusplus
 };
index aa8e7a63f4c2f01fc51a4c9193a5ea90fe931147..36a27dc0284fc8c77d97f30bb09f91f138b438c6 100644 (file)
@@ -27,7 +27,7 @@
 #include <inttypes.h>
 
 static int
-ext2lib_mount(fsi_t *fsi, const char *name)
+ext2lib_mount(fsi_t *fsi, const char *name, const char *options)
 {
        int err;
        char opts[30] = "";
index c3749df222c1d09a965554b577e983718d60a341..4a8f595f43e799ac535f94a2667fda43f7fc25c1 100644 (file)
@@ -321,7 +321,7 @@ ffz (unsigned long word)
 
 /* check filesystem types and read superblock into memory buffer */
 int
-ext2fs_mount (fsi_file_t *ffi)
+ext2fs_mount (fsi_file_t *ffi, const char *options)
 {
   int retval = 1;
 
index 4b99149735bea1fbf6b272cd4a765740c2575822..d1fd3efa1f6e072e83eb7c5551e25beec69690f1 100644 (file)
@@ -633,7 +633,7 @@ journal_init (fsi_file_t *ffi)
 
 /* check filesystem types and read superblock into memory buffer */
 int
-reiserfs_mount (fsi_file_t *ffi)
+reiserfs_mount (fsi_file_t *ffi, const char *options)
 {
   struct reiserfs_super_block super;
   int superblock = REISERFS_DISK_OFFSET_IN_BYTES >> SECTOR_BITS;
index f1cb917c8cd1a40b1964946c24106a3ca0c68ce3..d187dbf41447d250c3546abbb32274be17e7394a 100644 (file)
@@ -44,7 +44,7 @@ static grub_daddr32_t sbmap(fsi_file_t *, grub_daddr32_t);
 
 /* read superblock and check fs magic */
 int
-ufs_mount(fsi_file_t *ffi)
+ufs_mount(fsi_file_t *ffi, const char *options)
 {
        if (/*! IS_PC_SLICE_TYPE_SOLARIS(current_slice) || */
            !devread(ffi, UFS_SBLOCK, 0, UFS_SBSIZE, (char *)SUPERBLOCK) ||
index 52a8a4b1acb8122438bc21c8ec800426bd0484ff..21f9411c251d1498fe454d935e6d2c5c1bb5c1bd 100644 (file)
@@ -260,19 +260,20 @@ PyTypeObject fsimage_fs_type = {
 static PyObject *
 fsimage_open(PyObject *o, PyObject *args, PyObject *kwargs)
 {
-       static char *kwlist[] = { "name", "offset", NULL };
-       char * name;
+       static char *kwlist[] = { "name", "offset", "options", NULL };
+       char *name;
+       char *options = NULL;
        uint64_t offset = 0;
        fsimage_fs_t *fs;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|L", kwlist, 
-           &name, &offset))
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|Ls", kwlist, 
+           &name, &offset, &options))
                return (NULL);
 
        if ((fs = PyObject_NEW(fsimage_fs_t, &fsimage_fs_type)) == NULL)
                return (NULL);
 
-       if ((fs->fs = fsi_open_fsimage(name, offset)) == NULL) {
+       if ((fs->fs = fsi_open_fsimage(name, offset, options)) == NULL) {
                PyErr_SetFromErrno(PyExc_IOError);
                return (NULL);
        }
@@ -284,7 +285,8 @@ PyDoc_STRVAR(fsimage_open__doc__,
     "open(name, [offset=off]) - Open the given file as a filesystem image.\n"
     "\n"
     "name - name of file to open.\n"
-    "offset - offset of file system within file image.\n");
+    "offset - offset of file system within file image.\n"
+    "options - mount options string.\n");
 
 static struct PyMethodDef fsimage_module_methods[] = {
        { "open", (PyCFunction)fsimage_open,